﻿using System.Drawing;
using Simple3DRedactor.Domain;

namespace SceneRedactor
{
    class SphereView : GeometryView<Sphere>
    {
        public SphereView(Sphere obj) : base(obj)
        {
        }
        
        public override void ShowProperties(SimpleSceneRedactor redactor)
        {
            base.ShowProperties(redactor);

            redactor.sphereRadiusTextBox.Text = InnerObject.Radius.ToString();
            redactor.slicesTextBox.Text = InnerObject.Slices.ToString();
            redactor.stacksTextBox.Text = InnerObject.Stacks.ToString();

            redactor.SphereAndCylinderPropertiesGroupBox.Visible = true;
            redactor.SphereAndCylinderPropertiesGroupBox.Text = "Sphere properties";
            redactor.SphereAndCylinderPropertiesGroupBox.Location = new Point(redactor.specularLabel.Location.X, redactor.specularLabel.Location.Y + 20);
        }

        public override void SaveProperties(SimpleSceneRedactor redactor)
        {
            base.SaveProperties(redactor);

            InnerObject.Radius = float.Parse(redactor.sphereRadiusTextBox.Text);
            InnerObject.Stacks = int.Parse(redactor.stacksTextBox.Text);
            InnerObject.Slices = int.Parse(redactor.stacksTextBox.Text);
        }

        public override string ToString()
        {
            return string.Format("{0} [Sphere]", InnerObject.Name);
        }
    }
}
